BIN and BCD functions


Results 1 to 6 of 6

Thread: BIN and BCD functions

  1. #1
    Member
    Join Date
    Feb 2006
    Location
    india
    Posts
    1792
    Downloads
    0
    Uploads
    0

    Default BIN and BCD functions

    I was trying to figure out what these are. I understand the following (from the manual):
    BIN: converts BCD (Binary Coded Decimal) format to binary format
    BCD: converts binary format to BCD format

    While experimentibg on 0iTC, I found the following:
    BIN [41] returns 29.000
    BCD [29] returns 41.000
    BIN [10] illegal argument
    BCD [1000] returns 4096.000
    BCD[1000000] returns 16777216.
    BCD[a negative value] illegal argument
    BCD [fractional value] rounding to the nearest integer is automatically done, and then function is evaluated.
    etc.

    I could not derive any logic out of it. Can somebody please these explain these function is some detail.

    Similar Threads:


  2. #2
    Registered
    Join Date
    Jan 2007
    Location
    UK
    Posts
    42
    Downloads
    0
    Uploads
    0

    Default

    In binary coding each bit represents a power of two. In BCD the bits are grouped in fours and each group of four represents a decimal digit.

    The numeric parameter is always converted to binary and then passed to the functions so:

    BIN[41]: 41 in binary is 101001, interpreted in BCD that is 0010, 1001 i.e. 29.
    BCD[29] 29 in BCD is 0010, 1001, intepreted in binary is 101001 , i.e. 32+9 =41
    BIN[10] is illegal because binary 10 is 1010 which is not a BCD digit.
    BCD[1000] is 0001 0000 0000 0000 which is 2^12 i.e. 4096 when interpreted in binary.
    BCD[1000000] is 2^24



  3. #3
    Member
    Join Date
    Feb 2006
    Location
    india
    Posts
    1792
    Downloads
    0
    Uploads
    0

    Default

    Thanks.
    So, BIN converts a binary number to BCD
    and BCD converts a BCD to binary.
    Peter Smid also says the same thing in his book, but Fanuc manual says the opposite:
    (from Operator's Manual 0i Tc, page 266)
    Conversion from BCD to BIN, #i = BIN [#j];
    Conversion from BIN to BCD, #i = BCD [#j];

    This is the result of Japanese to English translation.



  4. #4
    Registered
    Join Date
    Jan 2007
    Location
    UK
    Posts
    42
    Downloads
    0
    Uploads
    0

    Default

    No BIN converts a BCD number to binary. BCD converts binary to BCD.

    The really confusing thing is that your input and output functions in the examples are always converting ascii to binary and binary to ascii. When you do BCD[29] the text 29 is converted to binary 11101 (16 + 8 + 4 + 1). The BCD function converts it to the BCD representation of 29 which 0010 1001. That is converted back to ascii to print the result but the conversion does not know it should be interpreted in BCD so it shows its binary value which is 32 + 8 + 1 = 41.

    The BCD representation only makes sense if it is sent to something that expects it to be BCD, for example the BIN function.



  5. #5
    Member
    Join Date
    Feb 2006
    Location
    india
    Posts
    1792
    Downloads
    0
    Uploads
    0

    Default

    Thanks again.
    Somebody told me that these functions have something to do with the interface signals, for the purpose of interacting with external devices connected to CNC. Can you please give just one example of these functions.



  6. #6
    Registered
    Join Date
    Jan 2007
    Location
    UK
    Posts
    42
    Downloads
    0
    Uploads
    0

    Default

    Sorry I have no idea why CNC would need them, it must be to interface to something that uses BCD.



Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

BIN and BCD functions

BIN and BCD functions